<?php

namespace catchAdmin\ce\controller;

use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catchAdmin\ce\model\Cc as CcModel;
use think\Response;

class Cc extends CatchController
{
    
    protected $ccModel;
    
    /**
     *
     * @time 2025/10/26 22:03
     * @param CcModel $ccModel
     * @return mixed
     */
    public function __construct(CcModel $ccModel)
    {
        $this->ccModel = $ccModel;
    }
    
    /**
     *
     * @time 2025/10/26 22:03
     * @return Response
     */
    public function index() : Response
    {
//        p((new \app\Request())->user()->toArray());

        return CatchResponse::paginate($this->ccModel->getList());
    }
    
    /**
     *
     * @time 2025/10/26 22:03
     * @param Request $request
     * @return Response
     */
    public function save(Request $request) : Response
    {
        return CatchResponse::success($this->ccModel->storeBy($request->post()));
    }
    
    /**
     *
     * @time 2025/10/26 22:03
     * @param $id
     * @return Response
     */
    public function read($id) : Response
    {
        return CatchResponse::success($this->ccModel->findBy($id));
    }
    
    /**
     *
     * @time 2025/10/26 22:03
     * @param $id
     * @param Request $request
     * @return Response
     */
    public function update($id, Request $request) : Response
    {
        return CatchResponse::success($this->ccModel->updateBy($id, $request->post()));
    }
    
    /**
     *
     * @time 2025/10/26 22:03
     * @param $id
     * @return Response
     */
    public function delete($id) : Response
    {
        return CatchResponse::success($this->ccModel->deleteBy($id));
    }
}